﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;

namespace Frogism.Data._2
{
    public class AccountRepository :Core.IAccountLoader
    {
        #region ILoader<Account,IAccount> Members

        public IEnumerable<Frogism.Core.IAccount> GetAll()
        {
            //var col = new System.Collections.ObjectModel.Collection<Core.IAccount>();
            //var obj = new NHibernate.Collection.Generic.PersistentGenericSet<Core.IAccount>();
            using ( ISession session = NHConfig.GetSessionFactory().OpenSession())
            {
                return session.CreateQuery("from Account where IsActive = :IsActive")
                    .SetBoolean("IsActive",true)
                    .List<Frogism.Core.IAccount>();
            }
        }

        public Frogism.Core.IAccount GetById(int id)
        {
            using (ISession session = NHConfig.GetSessionFactory().OpenSession())
            {
                return session.Get<Core.Account>(id);
            }
           
        }

        #endregion
    }
}
